<template>
  <div>
    <el-table :data="list" show-summary :summary-method="getSummaries">
      <el-table-column
        prop="city_name"
        label="城市"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="agent_name"
        label="代理商"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="shop_sn"
        label="店铺编号"
        align="center"
        min-width="150"
      ></el-table-column>
      <el-table-column
        prop="shop_name"
        label="店铺名称"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="company_name"
        label="公司名称"
        align="center"
      ></el-table-column>
      <el-table-column
        v-if="type === 'month'"
        prop="show_month"
        label="月份"
        width="120"
        align="center"
      >
      </el-table-column>

      <el-table-column
        v-if="type === 'week'"
        prop="week_num"
        label="周"
        width="120"
        align="center"
      >
        <template slot-scope="{ row }">
          <p>{{ row.week_num }}周</p>
          <p>{{ row.week_start.slice(5) }} ~ {{ row.week_end.slice(5) }}</p>
        </template>
      </el-table-column>

      <el-table-column
        v-if="type === 'day'"
        prop="show_day"
        label="日期"
        width="120"
        align="center"
      >
      </el-table-column>
      <el-table-column prop="should_recapture" label="本期应收" align="center">
        <template slot-scope="{ row }">
          <span class="cursor-pointer u" @click="reportDetails(row,'should')">
            {{ moneyUnitCent2Coin(row.should_recapture) }}
          </span>
        </template>
      </el-table-column>
      <el-table-column prop="reality_recapture" label="本期实收" align="center">
        <template slot-scope="{ row }">
          <span class="cursor-pointer u" @click="reportDetails(row,'reality')">
            {{ moneyUnitCent2Coin(row.reality_recapture) }}
          </span>
        </template>
      </el-table-column>
      <el-table-column prop="none_recapture" label="本期未收" align="center">
        <template slot-scope="{ row }">
          <span class="cursor-pointer u" @click="reportDetails(row,'none')">
            {{ moneyUnitCent2Coin(row.none_recapture) }}
          </span>
        </template>
      </el-table-column>
      <el-table-column prop="amass_should_recapture" label="累计应收" align="center">
        <template slot-scope="{ row }">
          {{ moneyUnitCent2Coin(row.amass_should_recapture) }}
        </template>
      </el-table-column>
      <el-table-column prop="amass_reality_recapture" label="累计实收" align="center">
        <template slot-scope="{ row }">
          {{ moneyUnitCent2Coin(row.amass_reality_recapture) }}
        </template>
      </el-table-column>
      <el-table-column prop="amass_none_recapture" label="累计未收" align="center">
        <template slot-scope="{ row }">
          {{ moneyUnitCent2Coin(row.amass_none_recapture) }}
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="paging"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>
<script>
export default {
  name: "Table",
  data() {
    return {};
  },
  props: {
    type: {
      type: String,
      default: "month",
    },
    list: {
      type: Array,
      default: () => [],
    },
    aggregate: {
      type: Object,
      default: () => {},
    },
    page: {
      type: Number,
      default: 1,
    },
    pageSize: {
      type: Number,
      default: 20,
    },
    total: {
      type: Number,
      default: 0,
    },
  },
  mounted() {},
  created() {},
  methods: {
    handleSizeChange(size) {
      this.$emit("page-size", { size, type: this.type });
    },
    handleCurrentChange(page) {
      this.$emit("page-num", { page, type: this.type });
    },
    //查看明细
    reportDetails(row,type){
      this.$router.push({
        path: '/reportDetails',
        query: {
          type: type,
          agent_id: row.agent_id,
          shop_id: row.shop_id,
          city_id: row.city_id,
          month: row.show_month,
        }
      })
    },
    //总计
    getSummaries() {
      try {
        return [
          "-",
          "-",
          "-",
          "-",
          "-",
          "总计",
          this.moneyUnitCent2Coin(this.aggregate.should_recapture),
          this.moneyUnitCent2Coin(this.aggregate.reality_recapture),
          this.moneyUnitCent2Coin(this.aggregate.none_recapture),
          "-",
          "-",
          "-",
        ];
      } catch (err) {
        console.log("----------err", err);
      }
    },
  },
};
</script>
<style scoped lang="scss">
.el-table {
  >>> .el-table__body-wrapper {
    min-height: auto;
  }
}
.paging {
  text-align: right;
  padding: 20px 0;
}
</style>



// WEBPACK FOOTER //
// src/components/sheet/component/FreelanCecollectionTable.vue